<template>
  <div class="app-container">
    <div v-if="user">
      <el-row :gutter="20">

        <el-col :span="6" :xs="24">
          <user-card :user="user" />
        </el-col>

        <el-col :span="18" :xs="24">
          <el-card>
            <el-tabs v-model="activeTab">
              <el-tab-pane label="Account" name="account">
                <account :user="user" />
              </el-tab-pane>
              <el-tab-pane label="Jira Config" name="jira-config">
                <jira-config :jira_config="jira_config" />
              </el-tab-pane>
            </el-tabs>
          </el-card>
        </el-col>

      </el-row>
    </div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import UserCard from './components/UserCard'
import Account from './components/Account'
import JiraConfig from "./components/JiraConfig";
import getQueryString from '@/utils/getCookies';
const getCookies = getQueryString.getCookie;

export default {
  name: 'Profile',
  components: { UserCard, Account, JiraConfig },
  data() {
    return {
      user: {},
      jira_config: {},
      activeTab: 'jira-config'
    }
  },
  computed: {
    ...mapGetters([
      'avatar',
    ])
  },
  created() {
    this.getUser()
  },
  methods: {
    getUser() {
      this.user = {
        name: getCookies('username'),
        // role: this.roles.join(' | '),
        email: getCookies('username') + '@magnumwm.com',
        avatar: this.avatar
      }
      this.jira_config = {
        username: getCookies('username'),
        password: ''
      }
    }
  }
}
</script>
